package api;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class IteratorStringTest {
    public static void main(String[] args) {
        Collection<String> collection = new ArrayList<>();
        collection.add("aa");
        collection.add("bb");
        collection.add("cc");
        collection.add("dd");
        System.out.println(collection);//[aa, bb, cc, dd]
        //用迭代器去遍历集合中的数据
        Iterator<String> iterator = collection.iterator();
        while (iterator.hasNext()){
            String next = iterator.next();//这一段没想出来
            System.out.println(next.toUpperCase());
        }
    }
}
